<?php

use app\adminapi\middleware\CheckPermission;
use app\adminapi\middleware\JwtAuth;
use app\adminapi\middleware\OperateLog;
use think\facade\Route;

// 管理员路由
Route::group('admin', function () {
    Route::get('index', 'permission.Admin/index')->name('admin:list')->setOption('real_name', '管理员列表');
    Route::get('read/:id', 'permission.Admin/read')->name('admin:detail')->setOption('real_name', '管理员详情');
    Route::post('save', 'permission.Admin/save')->name('admin:add')->setOption('real_name', '添加管理员');
    Route::put('update/:id', 'permission.Admin/update')->name('admin:update')->setOption('real_name', '编辑管理员');
    Route::delete('delete/:id', 'permission.Admin/delete')->name('admin:delete')->setOption('real_name', '删除管理员');
    Route::post('changePassword', 'permission.Admin/changePassword')->name('admin:changePassword')->setOption('real_name', '修改管理员密码');
})->middleware([JwtAuth::class, CheckPermission::class, OperateLog::class]);

// 菜单路由
Route::group('menu', function () {
    Route::get('index', 'permission.Menu/index')->name('menu:list')->setOption('real_name', '菜单路由列表');
    Route::get('read/:id', 'permission.Menu/read')->name('menu:detail')->setOption('real_name', '获取菜单详情');
    Route::post('save', 'permission.Menu/save')->name('menu:add')->setOption('real_name', '添加菜单');
    Route::put('update/:id', 'permission.Menu/update')->name('menu:update')->setOption('real_name', '编辑菜单');
    Route::delete('delete/:id', 'permission.Menu/delete')->name('menu:delete')->setOption('real_name', '删除菜单');
})->middleware([JwtAuth::class, CheckPermission::class, OperateLog::class]);

// 角色路由
Route::group('role', function () {
    Route::get('index', 'permission.Role/index')->name('role:list')->setOption('real_name', '角色列表');
    Route::get('read/:id', 'permission.Role/read')->name('role:detail')->setOption('real_name', '角色详情');
    Route::post('save', 'permission.Role/save')->name('role:add')->setOption('real_name', '添加角色');
    Route::put('update/:id', 'permission.Role/update')->name('role:update')->setOption('real_name', '编辑角色');
    Route::delete('delete/:id', 'permission.Role/delete')->name('role:delete')->setOption('real_name', '删除角色');
    Route::put('setRoleAuth/:id', 'permission.Role/setRoleAuth')->name('role:setRoleAuth')->setOption('real_name', '赋予角色权限');
})->middleware([JwtAuth::class, CheckPermission::class, OperateLog::class]);
